<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" /> 
<meta name="description" content="" />
<title>0.0.1</title>
<#include "../com/top.ftl">

<!--中间  主体内容-->
<div class="a_zhuce_text">
	<!--注册步骤-->
	<div class="a_zhuce_buzhou">
		<dl>
			<dt><img src="${ctx}/resources/images/daole/a_zhuce.png"/></dt>
			<dd class="active">用户验证 </dd>
		</dl>
		<dl style="padding:0 37%;">
		     <dt><img src="${ctx}/resources/images/daole/a_zhuce(hui).png"/></dt>
			 <dd>修改密码 </dd>
		</dl>
		<dl>
			<dt><img src="${ctx}/resources/images/daole/a_zhuce(hui3).png"/></dt>
			<dd>修改成功</dd>
		</dl>
	</div>
	
		
	<!--信息填写-->
	<form method="POST" action="${ctx}/doforget">
	<ul class="a_zhuce_info">
		<form method="POST" action="${ctx}/doregist${suffix}">
		<li>
			<span>手机号：</span>
			<input type="text" id="contact" name="contact" maxlength="11" placeholder="请输入您的手机号" onBlur="valContact(this)"/>
			<span id="contactCue" class="mx_tishi" ></span>
		</li>
		
		<li class="a_yanzhengma">
			<span>输入验证码：</span>
			<input type="text" placeholder="请输入验证码" name="valCode" id="valCode" maxlength="6" class="w_shur"/>
			<input id="btnSendCode" type="button" value="获取验证码" onClick="sendSMSForRegist()" class="zd-input03"  disabled="disabled" onclick="test();"/>
			<span id="codeCue" class="xm_p mx_tishi"></span>
		</li>
		
		
	</ul>
		
		<div class="a_next">
			<button type="submit" id="registBtn" class="onRegistBtn" onclick="return checkSub(this.form)" >下一步</button>
			 <!--<a href="0.0.1wangjimima2.html">下一步</a>-->
			 
		</div>
		
	</form>	
	</div>
</div>


<script type="text/javascript">


	function checkSub(){
		var names = "contact,手机号;valCode,验证码";
		var nullVal = checkCommit(names);
		if(nullVal == true && contactReg == true ){
			return true;
		}
		return false;
	}

	
	
	function valContact(){
		var contact = $("#contact").val(); //获取手机号
		var contactReg = !!contact.match(/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/);
		if(contactReg == false || contact.length>11){
			$("#contactCue").show();
			$("#btnSendCode").attr("disabled", true);//设置disabled属性
			$("#contactCue").text("请正确填写手机号码。");
			return false;
		}
		var url = "${ctx}/check_contact_is_exist/"+contact;
		var param = {};
		$.getJSON(url, param, function(data){
			if(data.error == false ){ // 手机注册过
				$("#btnSendCode").removeAttr("disabled"); //移除发送短信btn disabled属性
				$("#btnSendCode").attr("class","wait");
				$("#contactCue").text("");
				$("#contactCue").hide();
			}else{
				$("#contactCue").show();
				$("#contactCue").text("该手机号码未注册.");
			}
		});
		return true;
	}
	
	
	
	
	function sendSMSForRegist(){
    	var step = 60;
        $('#btnSendCode').val('重新发送'+step);
        $("#btnSendCode").attr("disabled", true);//设置disabled属性
        $("#btnSendCode").attr("class","w_yzm");
        var contact = $("#contact").val();
    	var _res = setInterval(function() {
            $('#btnSendCode').val('重新发送'+(step-1));
            $("#contact").removeAttr("onBlur");
            step-=1;
            if(step == 59){
            	var url = "${ctx}/sendsms_for_forget_password/"+contact;
				var param = {};
				$.getJSON(url, param, function(data){
					if(data.succ == true){ // 验证码发送成功
						$("#codeCue").show();
						$("#codeCue").text("验证码发送成功,请查收.");
					}else{
						$("#codeCue").show();
						$("#codeCue").text("+data.msg+");
					}
				});
            }
            if(step <= 0){
            	$("#contact").attr("onBlur","valContact('+contact+')");
                $("#btnSendCode").removeAttr("disabled"); //移除发送短信按钮disabled属性
                $('#btnSendCode').val('获取验证码'); // 改变btn的值
                $("#btnSendCode").attr("class","wait"); // 修改btm样式
                clearInterval(_res);//清除setInterval
            }
        },1000);
	}
	
	
	
	
	
	
	
</script>

<#include "../com/foot.ftl">